package com.tjec.project.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tjec.framework.aspectj.lang.annotation.Log;
import com.tjec.framework.aspectj.lang.enums.BusinessType;
import com.tjec.project.system.domain.SysRejectOpinion;
import com.tjec.project.system.service.ISysRejectOpinionService;
import com.tjec.framework.web.controller.BaseController;
import com.tjec.framework.web.domain.AjaxResult;
import com.tjec.common.utils.poi.ExcelUtil;
import com.tjec.framework.web.page.TableDataInfo;

/**
 * 流程驳回意见Controller
 * 
 * @author tjec
 * @date 2021-04-14
 */
@RestController
@RequestMapping("/system/opinion")
public class SysRejectOpinionController extends BaseController
{
    @Autowired
    private ISysRejectOpinionService sysRejectOpinionService;

    /**
     * 查询流程驳回意见列表
     */
    @PreAuthorize("@ss.hasPermi('system:opinion:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysRejectOpinion sysRejectOpinion)
    {
        startPage();
        List<SysRejectOpinion> list = sysRejectOpinionService.selectSysRejectOpinionList(sysRejectOpinion);
        return getDataTable(list);
    }

    /**
     * 导出流程驳回意见列表
     */
    @PreAuthorize("@ss.hasPermi('system:opinion:export')")
    @Log(title = "流程驳回意见", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysRejectOpinion sysRejectOpinion)
    {
        List<SysRejectOpinion> list = sysRejectOpinionService.selectSysRejectOpinionList(sysRejectOpinion);
        ExcelUtil<SysRejectOpinion> util = new ExcelUtil<SysRejectOpinion>(SysRejectOpinion.class);
        return util.exportExcel(list, "驳回意见");
    }

    /**
     * 获取流程驳回意见详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:opinion:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(sysRejectOpinionService.selectSysRejectOpinionByGuid(guid));
    }

    /**
     * 新增流程驳回意见
     */
    @PreAuthorize("@ss.hasPermi('system:opinion:add')")
    @Log(title = "流程驳回意见", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysRejectOpinion sysRejectOpinion)
    {
        return toAjax(sysRejectOpinionService.insertSysRejectOpinion(sysRejectOpinion));
    }

    /**
     * 修改流程驳回意见
     */
    @PreAuthorize("@ss.hasPermi('system:opinion:edit')")
    @Log(title = "流程驳回意见", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysRejectOpinion sysRejectOpinion)
    {
        return toAjax(sysRejectOpinionService.updateSysRejectOpinion(sysRejectOpinion));
    }

    /**
     * 删除流程驳回意见
     */
    @PreAuthorize("@ss.hasPermi('system:opinion:remove')")
    @Log(title = "流程驳回意见", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(sysRejectOpinionService.deleteSysRejectOpinionByGuids(guids));
    }
}
